import 'dart:convert' show json;

class GankGirlResponse {

  int page;
  int page_count;
  int status;
  int total_counts;
  List<GankGirlData> data;

  GankGirlResponse.fromParams({this.page, this.page_count, this.status, this.total_counts, this.data});

  factory GankGirlResponse(jsonStr) => jsonStr == null ? null : jsonStr is String ? new GankGirlResponse.fromJson(json.decode(jsonStr)) : new GankGirlResponse.fromJson(jsonStr);

  GankGirlResponse.fromJson(jsonRes) {
    page = jsonRes['page'];
    page_count = jsonRes['page_count'];
    status = jsonRes['status'];
    total_counts = jsonRes['total_counts'];
    data = jsonRes['data'] == null ? null : [];

    for (var dataItem in data == null ? [] : jsonRes['data']){
      data.add(dataItem == null ? null : new GankGirlData.fromJson(dataItem));
    }
  }

  @override
  String toString() {
    return '{"page": $page,"page_count": $page_count,"status": $status,"total_counts": $total_counts,"data": $data}';
  }
}

class GankGirlData {

  int likeCounts;
  int stars;
  int views;
  String id;
  String author;
  String category;
  String createdAt;
  String desc;
  String publishedAt;
  String title;
  String type;
  String url;
  List<String> images;

  GankGirlData.fromParams({this.likeCounts, this.stars, this.views, this.id, this.author, this.category, this.createdAt, this.desc, this.publishedAt, this.title, this.type, this.url, this.images});

  GankGirlData.fromJson(jsonRes) {
    likeCounts = jsonRes['likeCounts'];
    stars = jsonRes['stars'];
    views = jsonRes['views'];
    id = jsonRes['_id'];
    author = jsonRes['author'];
    category = jsonRes['category'];
    createdAt = jsonRes['createdAt'];
    desc = jsonRes['desc'];
    publishedAt = jsonRes['publishedAt'];
    title = jsonRes['title'];
    type = jsonRes['type'];
    url = jsonRes['url'];
    images = jsonRes['images'] == null ? null : [];

    for (var imagesItem in images == null ? [] : jsonRes['images']){
      images.add(imagesItem);
    }
  }

  @override
  String toString() {
    return '{"likeCounts": $likeCounts,"stars": $stars,"views": $views,"_id": ${id != null?'${json.encode(id)}':'null'},"author": ${author != null?'${json.encode(author)}':'null'},"category": ${category != null?'${json.encode(category)}':'null'},"createdAt": ${createdAt != null?'${json.encode(createdAt)}':'null'},"desc": ${desc != null?'${json.encode(desc)}':'null'},"publishedAt": ${publishedAt != null?'${json.encode(publishedAt)}':'null'},"title": ${title != null?'${json.encode(title)}':'null'},"type": ${type != null?'${json.encode(type)}':'null'},"url": ${url != null?'${json.encode(url)}':'null'},"images": $images}';
  }
}

